package com.xuebank.nfe.nfecar.model

import android.os.Parcel
import android.os.Parcelable
import java.util.ArrayList

/**
 * author: shell
 * date 2016/12/30 下午3:37
 */
class TagGroupModel(var tags: MutableList<Tag> ? = ArrayList(),
                    var percentX: Float = 0.toFloat(),
                    var percentY: Float = 0.toFloat()) :Parcelable {



    constructor(parcel: Parcel) : this(
            parcel.createTypedArrayList(Tag),
            parcel.readFloat(),
            parcel.readFloat()) {
    }



    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeTypedList(tags)
        parcel.writeFloat(percentX)
        parcel.writeFloat(percentY)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<TagGroupModel> {
        override fun createFromParcel(parcel: Parcel): TagGroupModel {
            return TagGroupModel(parcel)
        }

        override fun newArray(size: Int): Array<TagGroupModel?> {
            return arrayOfNulls(size)
        }
    }





    class Tag(var name: String? = "",
              var link: String? = "",
              var direction: Int = 0,
              var id: Int = 0) :Parcelable {



        override fun writeToParcel(dest: Parcel?, flags: Int) {
            dest?.writeString(name)
            dest?.writeString(link)
            dest?.writeInt(direction)
            dest?.writeInt(id)
        }

        override fun describeContents(): Int {
            return 0
        }

        constructor(parcel: Parcel) : this() {
            name = parcel.readString()
            link = parcel.readString()
            direction = parcel.readInt()
            id = parcel.readInt()
        }

        companion object CREATOR : Parcelable.Creator<Tag> {
            override fun createFromParcel(parcel: Parcel): Tag {
                return Tag(parcel)
            }

            override fun newArray(size: Int): Array<Tag?> {
                return arrayOfNulls(size)
            }
        }

    }
}